package com.example.yeujian5.yuejian5.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.yeujian5.yuejian5.Listenner.MatchListener;
import com.example.yeujian5.yuejian5.R;
import com.example.yeujian5.yuejian5.adapter.MatchAdapter;
import com.example.yeujian5.yuejian5.bean.MatchBean;
import com.example.yeujian5.yuejian5.model.MatchModel;

import java.util.List;

/**
 * Created by wangmengmeng on 2017/10/7.
 */

public class MatchFragment extends Fragment implements MatchListener {

    private RecyclerView recyclerView;
    List<MatchBean> list;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState)
    {
        View view=inflater.inflate(R.layout.fragment_match, container, false);
        initRecyclerView(view);
        MatchModel model=new MatchModel();
        model.getList("45","",this);
        return  view;
    }

    public  void initRecyclerView(View view){

        recyclerView= (RecyclerView) view.findViewById(R.id.match_Rec);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }

    @Override
    public void onResponse(List<MatchBean> listBeen) {
        list=listBeen;
        recyclerView.setAdapter(new MatchAdapter(getActivity(),list));
    }

    @Override
    public void onFail(String msg) {
        Toast.makeText(getActivity(), ""+msg, Toast.LENGTH_SHORT).show();
    }
}

